package com.library.uiframework.mvp;

import rx.Observable;
import rx.Subscriber;
import rx.Subscription;

/**
 * Created by HanikLZ on 2015/9/23.
 *
 * @author h.z
 * @version 1.0.0
 */
public class BasePresenter<VIEW> implements IPageLifecycle {
    final protected VIEW mBindView;

    final private Executor mExecutor = new Executor();
    private boolean mViewCreated;

    /**
     * 构造方法
     * @param view 绑定的视图对象
     */
    public BasePresenter(VIEW view) {
        mBindView = view;
    }

    protected <T> Subscription execute(Observable<T> observable, Subscriber<T> subscriber) {
        return mExecutor.execute(observable, subscriber);
    }

    @Override
    public void onCreate() {

    }

    @Override
    public void onStart() {

    }

    @Override
    public void onResume() {

    }

    @Override
    public void onPause() {

    }

    @Override
    public void onStop() {

    }

    @Override
    public void onDestroy() {
        mExecutor.unsubscribeAll();
    }

    public void onViewCreated() {
        mViewCreated = true;
    }

    public boolean isViewCreated() {
        return mViewCreated;
    }
}

